<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 准备好容器 -->
    <div id="test">
    </div>
</body>
<!-- 引入依赖 引入的时候，必须就按照这个步骤-->
<script src="../React-js/react.development.js" type = "text/javascript"></script>
<script src = "../React-js/react-dom.development.js" type = "text/javascript"></script>
<script src="../React-js/babel.min.js" type="text/javascript"></script>


<script type="text/babel">
    
    class Login extends React.Component{

        handleSubmit = (event)=>{
            event.preventDefault()//阻止表单提交
            const {username,password} = this
            alert(`用户名：${username.value}，密码：${password.value}`)
        }
        render(){
            return (
                <form onSubmit={this.handleSubmit}>
                    用户名：<input ref={c => this.username = c} type = "text" name = "username"/>
                    密码：<input ref={c => this.password = c} type = "password" name = "password"/>
                    <button>登陆</button>    
                </form>
            )
        }
    }

    ReactDOM.render(<Login/>,document.getElementById("test"))
</script>
</html>